package com.vincent.message;

import com.vincent.common.Message;
import com.vincent.common.MessageType;
import com.vincent.utils.BallotNumber;

/**
 * Created by wensen on 2016/12/7.
 *
 * 由Scouts或Commanders发送给Leaders的消息
 * 表示目前的ballot太小，即目前已经有更大ballot占有了Acceptors
 * 消息中携带ballot
 *
 */
public class PreemptedMessage extends Message{

    private final BallotNumber ballot_number;
    public PreemptedMessage(int src, BallotNumber ballot) {
        super(src);
        this.ballot_number = ballot;
    }

    public BallotNumber ballot_number() {
        return this.ballot_number;
    }

    public int messageType() {
        return MessageType.PREEMPTED_MESSAGE;
    }

    public String toString() {
        return "{PreemptedMessage [src: " + src() +
                " ballot: " + ballot_number + "]}";
    }
}
